package com.zjgeport.zjgdanger.Analysis;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.Toast;

import com.soar.util.net.rmi.httpxml.HttpCallBack;
import com.soar.util.net.rmi.httpxml.HttpClient;
import com.soar.util.net.rmi.httpxml.HttpMethod;
import com.soar.util.net.rmi.httpxml.HttpResult;
import com.zjgeport.zjgdanger.CommonActivity;
import com.zjgeport.zjgdanger.Exception.AccidentMainActivity;
import com.zjgeport.zjgdanger.Exception.ExceptionMainActivity;
import com.zjgeport.zjgdanger.Exception.IllegalMainActivity;
import com.zjgeport.zjgdanger.LoginActivity;
import com.zjgeport.zjgdanger.R;
import com.zjgeport.zjgdanger.adapter.AppGridAdapter;
import com.zjgeport.zjgdanger.common.ParamCommon;
import com.zjgeport.zjgdanger.model.myApplication;

import java.util.ArrayList;
import java.util.HashMap;

public class AnalysisMainActivity extends CommonActivity {

    private AppGridAdapter saItem;
    private GridView gv_one;
    private ArrayList<HashMap<String, Object>> meumList = new ArrayList<HashMap<String, Object>>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_analysis_main);
        initCommonListener();
        initView();
    }

    private void initView() {
        findTextViewById(R.id.title).setText("统计分析");
        String names01[] = { "危货品名统计", "甲乙丙货物数量统计","集装箱危货总量统计","按危险类别统计","异常报警数量变化图","企业异常统计图"};
        int draws01[] = { R.drawable.btn_exception_item1, R.drawable.btn_abc_item, R.drawable.btn_container_item, R.drawable.btn_danger_item, R.drawable.btn_exception_item2, R.drawable.btn_company_item};
        gv_one = (GridView)findViewById(R.id.GridView_app);
        gv_one.setSelector(new ColorDrawable(Color.TRANSPARENT));
        for (int i = 0; i < names01.length; i++)
        {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("ItemImage", draws01[i]); // 为加载数据设置图标
            map.put("ItemText", names01[i]); // 设置其名称
            meumList.add(map);
        }

        // 为适配器中数据设置布局样式
        int widthScreen  = getWindow().getWindowManager().getDefaultDisplay().getWidth();
        saItem = new AppGridAdapter(AnalysisMainActivity.this, meumList,widthScreen - 3*14,0,0);
        gv_one.setAdapter(saItem); // 为应用网格视图增加数据来源
        gv_one.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent;
                switch (i){
                    case 0:
                        Intent intent1 = new Intent(AnalysisMainActivity.this, DangerNameTJActivity.class);
                        startActivity(intent1);
                        break;
                    case 1:
                        Intent intent2 = new Intent(AnalysisMainActivity.this, GoodsCountTjActivity.class);
                        startActivity(intent2);
                        break;
                    case 2:
                        Intent intent3 = new Intent(AnalysisMainActivity.this,ContainerTotalTJActivity.class);
                        startActivity(intent3);
                        break;
                    case 3:
                        Intent intent4 = new Intent(AnalysisMainActivity.this,DangerTypeTJActivity.class);
                        startActivity(intent4);
                        break;
                    case 4:
                        Intent intent5 = new Intent(AnalysisMainActivity.this,ExceptionCountTJActivity.class);
                        startActivity(intent5);
                        break;
                    case 5:
                        Intent intent6 = new Intent(AnalysisMainActivity.this,CompanyExceptionTJActivity.class);
                        startActivity(intent6);
                        break;
                }
            }
        });
    }
}
